package Day11;

import java.util.Scanner;

/**
 * @author HYHwtx
 * @version 1.0
 * @date 2022/2/17 9:16
 */

//2.5	找出前n个质数，以数组的形式返回结果。
public class Test05 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入要获得的质数数量：");
        int num = in.nextInt();
        int[] nums = new int[num];
        int number = 2;//判断的数
        int index = 0;//表示下标
        while (true){
            boolean b=true;
            for (int i = 2; i < number; i++) {
                if (number%2==0){
                    b=false;
                    break;
                }
            }
            if (b){
                nums[index++]=number;
            }
            if (index == nums.length){
                break;
            }
            number++;
        }
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i]+" ");
        }

    }
}
